<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<base th:href="@{/}"/>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/Managerstyle.css" />
<style>
	table tr td{
		border-right: 1px solid #ddd;
	}
	table tr th:first-child{
		border-right: 1px solid #ddd;
		width: 150px !important;
	}
	table tr th{
		border-right: 1px solid #ddd;
		text-align: center;
		font-weight: 500;
	}
	select{
		display: inline;
	    height: 34px;
	    padding: 6px 12px;
	    font-size: 14px;
	    line-height: 1.42857143;
	    color: #555;
	    background-color: #fff;
	    background-image: none;
	    border: 1px solid #ccc;
	    border-radius: 4px;
	    width:150px;
	}
	button{
		height: 25px !important;
		line-height: 25px !important;
		font-size: 14px !important;
		padding: 0px 12px !important;	
	}
	input{
		border-radius: 4px;
		border: 1px solid #ccc;
		margin-bottom: 6px;
	} 
</style>
</head>
<body>


	<h3>查看课表</h3>
	<div>
			请选择学期：
		<select id="selectTyear">
			<option value="">请选择年份</option>
			<option th:each="year:${yearList}" th:value="${year}" th:text="${year}"></option>
		</select>
		<select id="selectTermNmae">
			<option value="">请选择学期</option>
		</select>
	</div>
	<div style="overflow:hidden;"></div>
	<div style="float: left;  margin-top: 5px;">
		
		请输入周次：
		<input type="text" id="cycle1" />
		<button class="btn btn-success" id="selectSchedule1" type="button">查询</button>
		<input type="hidden" id="bid" th:value="${session.loginStudent.batch.bid}"/> <br />
	</div>
	
	
	<div style="float: left; margin-top: 5px;">
		<span>选择教室</span>
		<select id="selectBuild" style="width: 150px;">
			<option>请选择教学楼</option>
			<option th:each="building:${buildlist}" th:value="${building.buildingId}" th:text="${building.buildname}"></option>
		</select>
		<select id="selectClassrm" name="classrmid" style="width: 130px;">
			<option>请选择教室</option>
		</select>
		<br>
		<!-- <input type="text" id="classrmid" /> <br /> -->
		请输入周次：
		<input type="text" id="cycle2" />
		<button class="btn btn-success" id="selectSchedule2" type="button">查询</button>
	</div>
	
	

	<table class="table" id="table">
		<tr>
			<th></th>
			<th>周一</th>
			<th>周二</th>
			<th>周三</th>
			<th>周四</th>
			<th>周五</th>
			<th>周六</th>
			<th>周七</th>
		</tr>
		<tr>
			<th>第1节</th>
			<td id="td1_1"></td>
			<td id="td2_1"></td>
			<td id="td3_1"></td>
			<td id="td4_1"></td>
			<td id="td5_1"></td>
			<td id="td6_1"></td>
			<td id="td7_1"></td>
		</tr>
		<tr>
			<th>第2节</th>
			<td id="td1_2"></td>
			<td id="td2_2"></td>
			<td id="td3_2"></td>
			<td id="td4_2"></td>
			<td id="td5_2"></td>
			<td id="td6_2"></td>
			<td id="td7_2"></td>
		</tr>
		<tr>
			<th>第3节</th>
			<td id="td1_3"></td>
			<td id="td2_3"></td>
			<td id="td3_3"></td>
			<td id="td4_3"></td>
			<td id="td5_3"></td>
			<td id="td6_3"></td>
			<td id="td7_3"></td>	
		</tr>
		<tr>
			<th>第4节</th>	
			<td id="td1_4"></td>
			<td id="td2_4"></td>
			<td id="td3_4"></td>
			<td id="td4_4"></td>
			<td id="td5_4"></td>
			<td id="td6_4"></td>
			<td id="td7_4"></td>
		</tr>
		<tr>
			<th>第5节</th>
			<td id="td1_5"></td>
			<td id="td2_5"></td>
			<td id="td3_5"></td>
			<td id="td4_5"></td>
			<td id="td5_5"></td>
			<td id="td6_5"></td>
			<td id="td7_5"></td>
		</tr>
		<tr>
			<th>第6节</th>
			<td id="td1_6"></td>
			<td id="td2_6"></td>
			<td id="td3_6"></td>
			<td id="td4_6"></td>
			<td id="td5_6"></td>
			<td id="td6_6"></td>
			<td id="td7_6"></td>
		</tr>
		<tr>
			<th>第7节</th>
			<td id="td1_7"></td>
			<td id="td2_7"></td>
			<td id="td3_7"></td>
			<td id="td4_7"></td>
			<td id="td5_7"></td>
			<td id="td6_7"></td>
			<td id="td7_7"></td>
		</tr>
		<tr>
			<th>第8节</th>
			<td id="td1_8"></td>
			<td id="td2_8"></td>
			<td id="td3_8"></td>
			<td id="td4_8"></td>
			<td id="td5_8"></td>
			<td id="td6_8"></td>
			<td id="td7_8"></td>
		</tr>
		<tr>
			<th>第9节</th>
			<td id="td1_9"></td>
			<td id="td2_9"></td>
			<td id="td3_9"></td>
			<td id="td4_9"></td>
			<td id="td5_9"></td>
			<td id="td6_9"></td>
			<td id="td7_9"></td>
		</tr>
		<tr>
			<th>第10节</th>
			<td id="td1_10"></td>
			<td id="td2_10"></td>
			<td id="td3_10"></td>
			<td id="td4_10"></td>
			<td id="td5_10"></td>
			<td id="td6_10"></td>
			<td id="td7_10"></td>
		</tr>
	</table>
	
	<script>
		$(document).ready(function(){
			$("#selectBuild").change(function(){
				var str2 = "<option>请选择</option>" ; 
				$.ajax({
					url: "stu/getClassrmByBuildid",
					type: "GET",
					data: {buildingId: $("#selectBuild").val()},
					success: function(data){
						var str1 = "";
						$("#selectClassrm").empty();
						$("#selectClassrm").append(str2);
						$.each(data,function(index,value){
							str1 = "<option value='" + value.classrmid +"'>" + value.clrnum + "</option>";
							$("#selectClassrm").append(str1);
						});					
					},
					error: function(req,status,error){
						$("#selectClassrm").empty();
						$("#selectClassrm").append(str2);
					}
				});
				
			});	
			
			
			$("#selectTyear").change(function(){
				var str = "<option value=''>请选择学期</option>";
				$.ajax({
					url: "stu/selectTermByTyear",
					type: "GET",
					data: {tyear: $("#selectTyear").val()},
					success: function(data){
						$("#selectTermNmae").empty();
						$.each(data, function(index,value){
							var str1 = "<option value='" + value.termId + "'>" + value.termName + "</option>";
							$("#selectTermNmae").append(str1);
						});
					},
					error: function(req, status, error)	{
						$("#selectTermNmae").empty();
						$("#selectTermNmae").append(str);
					}
				});
			});
			
			$("#selectSchedule1").click(function(){
				
			 	$.ajax({
					url: 'stu/getScheduleByBidAndCycle',
					type: 'GET',
					data: {bid: $("#bid").val(),cycle: $("#cycle1").val(), termId: $("#selectTermNmae").val()},
					success: function(data){
						$("#table tr td").html("");
						$.each(data,function(index,value){
							var str1 = value.coursePlan.lessionPlan.course.cname + "<br />" +
							value.coursePlan.teacher.tname + "<br />" + 
							value.classroom.building.buildname + value.classroom.clrnum + "<br>" + 
							value.cycle ;
							$("#td"+value.sweek+"_"+value.strtime).html(str1);
						});
						
					},
					error: function(req,status,error){
						$("#table tr td").html("");
					}
				}); 
				
			});
			
			$("#selectSchedule2").click(function(){
			 	$.ajax({
					url: 'stu/getScheduleByClassrmIdAndCycle',
					type: 'GET',
					data: {classrmid: $("#selectClassrm").val(), cycle: $("#cycle2").val()},
					success: function(data){
						$("#table tr td").html("");
						$.each(data,function(index,value){
							var str1 = value.coursePlan.lessionPlan.course.cname + "<br />" +
							value.coursePlan.teacher.tname + "<br />" + 
							value.classroom.building.buildname + value.classroom.clrnum + "<br>" + 
							value.cycle ;
							$("#td"+value.sweek+"_"+value.strtime).html(str1);
						});
						
					},
					error: function(req,status,error){
					}
				}); 
				
			});
			
			
		});
	</script>

</body>
</html>